perm filename EMAIN2.2[EAL,HE] blob
sn#704720 filedate 1983-03-27 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00003 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 {$NOMAIN Editor: single-character command executor }
C00006 00003 procedure eDo1Cmd (ch: ascii iCh: integer var done, minus, okp: boolean
C00015 ENDMK
C⊗;
{$NOMAIN Editor: single-character command executor }
{ This part handles all the single commands except I, Space and ! }
{ Those are handled by emain7 }
%include emain.hdr;
{ Externally defined routines from elsewhere: }
(* From EAUX1A *)
procedure adjustDisplay; external;
(* From EAUX2B *)
procedure nextStmnt(i: integer; downp: boolean); external;
procedure lastStmnt(i: integer; downp: boolean); external;
procedure parentStmnt(n: integer); external;
(* From EAUX2C *)
procedure displayLines(var pfrom: integer); external;
(* From EPAR3B *)
procedure labelParse; external;
(* From EPAR3D *)
procedure delStmnt(arg: integer); external;
(* From EAUX3A *)
procedure bracketStmnt; external;
procedure gotoMark(n: integer); external;
(* From EAUX3B *)
procedure redrawDisplay; external;
(* From IINIT - also in Level 3 *)
procedure killarms; external;
(* From PP *)
procedure ppLine; external;
procedure ppOutNow; external;
procedure ppChar(ch: ascii); external;
procedure pp5(ch: c5str; length: integer); external;
procedure pp10(ch: cstring; length: integer); external;
procedure pp10L(ch: cstring; length: integer); external;
procedure pp20(ch: c20str; length: integer); external;
procedure pp20L(ch: c20str; length: integer); external;
procedure ppInt(i: integer); external;
procedure eDo1Cmd (ch: ascii; iCh: integer; var done, minus, okp: boolean;
oldline, oldcline, arg: integer; var oc: integer); external;
procedure eDo1Cmd;
var b: boolean; i: integer;
begin
if iCh < 40B then ch := chr(iCh + 100B); (* Convert to a real char *)
case ch of
'E': begin
done := true; (* Set flag so program exits *)
killArms; (* Tell ARM module to exit *)
end;
'V': begin
redrawDisplay;
oc := 0; (* so we'll redisplay ">" cursor *)
end;
'L': begin
cursorLine := arg; (* new line number *)
setCursor := true;
adjustDisplay; (* make sure it's on screen *)
displayLines(lineNum); (* print out the statement *)
end;
'W',
'U',
'T',
'B': begin
if (ch = 'T') or (ch = 'U') then arg := - arg; (* rolling down *)
if (ch <= 'T') then lineNum := lineNum + 4 * arg (* glitches *)
else
begin
lineNum := lineNum + (dispHeight-1) * arg; (* screenfuls *)
if ch = 'W' then cursorLine := lineNum (* move cursor too *)
else cursorLine := lineNum + dispHeight - 1;
setCursor := true;
end;
displayLines(lineNum);
end;
'↑',
'S',
'N',
'<',
'>',
'H',
'M': begin (* backspace & return *)
if (ch = 'H') or (ch = '<') then arg := - arg; (* rolling down *)
if (ch = '<') or (ch = '>') then cursorLine := cursorLine + 4 * arg
else if ch = '↑' then parentStmnt(abs(arg)) (* up n levels *)
else if (ch = 'S') or (ch = 'N') then
if minus then lastStmnt(-arg,ch='S') (* up n stmnts *)
else nextStmnt(arg,ch='S') (* down n stmnts *)
else cursorLine := cursorLine + arg;
if cursorLine < 1 then cursorLine := 1
else if cursorLine > dprog↑.nlines then cursorLine := dprog↑.nlines;
adjustDisplay; (* make sure cursor is on screen *)
setCursor := true;
displayLines(lineNum);
end;
'P': begin
if minus then (* put cursorLine at bottom of screen *)
lineNum := cursorLine - dispheight + 1
else lineNum := cursorLine; (* put cursorLine at top of screen *)
displayLines(lineNum); (* shift the display *)
end;
'O': begin
cursorLine := oldcline; (* jump back to where we were *)
if (cursorLine < lineNum) or
(lineNum + dispHeight - 1 < cursorLine) then
lineNum := oldline;
setCursor := true;
displayLines(lineNum);
end;
'G': begin
i := cursorLine;
gotoMark(arg); (* for now can only go to marks *)
if i <> cursorLine then
begin
setCursor := true;
adjustDisplay;
displayLines(lineNum); (* print out the statement *)
end;
end;
'D': begin
if (arg = 1) and (fieldNum = 0) and cursorStack[cursor].stmntp then
begin (* just flush statement label *)
curChar := 1;
maxChar := 0;
labelParse;
end
else delStmnt(arg);
lineNum := topDline + firstDline - 1;
oc := 0; (* so we'll redisplay ">" cursor *)
end;
'Y': begin (* for now dump cursorStack *)
if ppBufp > 0 then ppLine;
for i := 1 to cursor do
with cursorStack[i] do
begin
ppInt(i); pp10(' - line: ',9); ppInt(cline);
if stmntp then
begin pp10(' stmnt: ',8); ppInt(ord(st↑.stype));
ppChar(' '); ppInt(st↑.nlines) end
else begin pp10(' node: ',7); ppInt(ord(nd↑.ntype)) end;
if i = cursor then begin ppchar(' '); ppInt(fieldNum) end;
ppLine;
end;
end;
'A',
'C': begin
pp20L(' Can''t attach/copy c',20); pp10('ode yet ',7);
ppLine;
okp := false;
end;
'F': begin
pp20L(' Find won''t work for',20); pp20(' a long while yet ',17);
ppLine;
okp := false;
end;
'[': bracketStmnt;
'?': begin
pp20L('Don''t panic. ',12); ppLine;
okp := false;
end;
'@': begin (* Move cursor to current pc *)
cursorLine := pcLine;
setCursor := true;
adjustDisplay;
displayLines(lineNum); (* shift display if necessary *)
end;
otherwise
begin (* ??? *)
pp20L(' Unknown command ',17); ppLine;
okp := false;
end;
end
end (* eDoCmd *);